package com.tarena.lbs.basic.web.controller;

import com.tarena.lbs.base.protocol.exception.BusinessException;
import com.tarena.lbs.base.protocol.model.Result;
import com.tarena.lbs.base.protocol.pager.PageResult;
import com.tarena.lbs.basic.web.service.BusinessService;
import com.tarena.lbs.common.passport.enums.Roles;
import com.tarena.lbs.pojo.basic.param.BusinessParam;
import com.tarena.lbs.pojo.basic.query.BusinessQuery;
import com.tarena.lbs.pojo.basic.vo.BusiStoreVO;
import com.tarena.lbs.pojo.basic.vo.BusinessVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 和商家业务相关的接口
 */
@RestController
public class BusinessController {
    @Autowired
    private BusinessService businessService;
    //查询商家列表
    @GetMapping("/admin/basic/business/info/list")
    public Result<PageResult<BusinessVO>> businessPage(BusinessQuery query) throws BusinessException {
        return new Result<>(businessService.businessPage(query));
    }

    //表单提交新增
    //form表单传参  name=wch&age=18
    //json请求体传参 {"name":"wch","age":18}
    //path路径参数 /user/detail/{name}/{age}
    @PostMapping("/admin/basic/business/info/save")
    public Result<Void> save(@RequestBody BusinessParam param) throws BusinessException {
        businessService.save(param);
        return Result.success();//code=0 message=null data=null
    }

    //活动查询中 查看当前活动绑定的商家详情及相关的店铺详情
    @GetMapping("/basic/business/info/detail/{id}")
    public Result<BusiStoreVO> businessStores(@PathVariable("id") Integer businessId) throws BusinessException {
        return new Result<>(businessService.businessStores(businessId));
    }

















}
